<template>
	<view class="">
		<view class="pd pt20  pm10 bgff display-flex fxxcvxcrtr">
			<view class=" flex-1 pr">
				<icon type="search" class="skjjxcerert" size="22"></icon>
				<input v-model="queryLike" type="text" confirm-type="search" class="xjhsddfr"
				 @confirm="dfsdstrertt"
					placeholder="请输入关键词进行搜索" />
			</view>
		</view>
		<view class="display-flex bgff pd pt20 pm20">
			<view class="flex-1 fz32 b">
				精选企业
			</view>
			<view class="" @tap="kxzcxrtxe">
				<text class="ls fz28">{{jmxr}}</text>
				<text class="iconfont icon-shaixuan ls fz30 cz"></text>
			</view>
		</view>
		<view class="pd">
			<view class="mt20 jmxcxzrtyt display-flex pd pt20 pm20" v-for="sd in jmxcdf" @tap="hf('details?id='+sd.id)">
				<view class="kkxzczxrett">
					<frImage :src="sd.companyImg" class=" cz"></frImage>
				</view>
				<view class="flex-1 ml20 vertical-center tl">
					<view class="">
						<view class="fz36 b">
							{{sd.companyName}}
						</view>
						<view class="mt10 z9 fz24">
							{{sd.companyAddr}}
						</view>
						<view class="mt20">
							<text class="tag-label">在招岗位数{{sd.jobNum||'0'}}个</text>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script lang="ts" setup>
	import { ref } from "vue"
	import { hf, dxrequest } from "@/util/index.js"
	import { onLoad,onReachBottom } from "@dcloudio/uni-app"
	import frImage from "@/components/fr-image/fr-image.vue"
	const kkmxd = ['推荐', '最新']
	const jmxr = ref("推荐")
	const queryLike = ref()
	const orderField = ref("is_good")
	const jmxcdf = ref([])
	const page = ref(1)
	const kxzcxrtxe = () => {
		uni.showActionSheet({
			itemList: kkmxd,
			success: (data) => {
				jmxr.value = kkmxd[data.tapIndex]
				if (data.tapIndex == 0) {
					orderField.value = "is_good"
				} else {
					orderField.value = "create_time"
				}
				page.value = 1
				jmxcdf.value = []
				kxczdf()
			}
		})
	}
	const kxczdf = async () => {
		const { data } = await dxrequest("/api/tmcompany/listByType", {
			limit: 10,
			page:page.value,
			orderField: orderField.value,
			queryLike: queryLike.value,
			order:"desc"
		})
		data.list.map(a=>{
			jmxcdf.value.push(a)
		})

	}
	kxczdf()
	const dfsdstrertt = ()=>{
		page.value = 1
		jmxcdf.value = []
		kxczdf()
	}
	onReachBottom(() => {
		page.value++
		kxczdf()
	})
</script>

<style scoped>
	.jmxcxzrtyt {
		border-radius: 8rpx;
		background: #fff;
	}

	.kkxzczxrett {
		width: 180rpx;
		height: 180rpx;
	}
</style>